package com.njtoyo.taxi.admin.rest.controller.business;

import com.alibaba.fastjson.JSONObject;
import com.njtoyo.taxi.admin.rest.presenter.platfrom.AdminUserIdentityPresenter;
import com.njtoyo.taxi.admin.service.business.RideRefundLogService;
import com.njtoyo.taxi.entity.backend.AdminUser;
import com.taxi.entity.common.RestResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("business/finance/ride-refund-log")
@RequiredArgsConstructor
@Slf4j
public class RideRefundLogController {
    private final RideRefundLogService rideRefundLogService;


    @GetMapping("/page")
    public RestResult page(@RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
                           @RequestParam(value = "size", required = false, defaultValue = "15") Integer size,
                           @RequestParam Map<String, String> params,
                           @ModelAttribute("admin") AdminUser adminUser) {
        AdminUserIdentityPresenter identity = (AdminUserIdentityPresenter)adminUser.getIdentity();
        switch (adminUser.getAccountType()) {
            case company:
                params.put("companyIds", JSONObject.toJSONString(identity.getCompanyIds()));
                break;
            case canton:
                params.put("cantonIds", JSONObject.toJSONString(identity.getCantonIds()));
                break;
        }
        return rideRefundLogService.page(current, size, params);
    }



}
